package javaLearning.时间;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoField;

/**
 * @author kkmytery
 * @description TimeDemo
 * @date 2020/12/16 1:35 下午
 */
public class TimeDemo {
    public static void main(String[] args) {
        LocalDateTime localDateTime=LocalDateTime.now();
        LocalDate localDate = localDateTime.toLocalDate();
        LocalTime localTime = localDateTime.toLocalTime();

        //改用DateTimeFormatter是为了保证线程安全
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        localDateTime.format(DateTimeFormatter.BASIC_ISO_DATE);
        localDateTime.format(dateTimeFormatter);
    }
}
